<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.is.util.ParamUtil"%>
<%@page import="com.is.util.DesData"%>
<%@page import="com.is.model.Student"%>
<%@page import="com.is.control.StudentControl"%>
<%@page import="com.is.util.DateTime"%>
<%@page import="com.is.control.ParamStuyearControl"%>
<%@page import="com.is.control.AttendanceDetailControl"%>
<%@page import="java.util.List"%>
<%@page import="com.is.model.CourseClass"%>
<%@page import="com.is.control.CourseClassControl"%>
<%@page import="com.is.control.ParamCourseControl"%>
<%@page import="com.is.control.DictationControl"%>
<%@page import="com.is.control.HomeworkControl"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="/InterStu/resources/image/favicon.ico" />
<script type="text/javascript" src="resources/js/jquery-1.8.1.js"></script>
<link rel="stylesheet" type="text/css" href="resources/css/common.css"/>
<link rel="stylesheet" type="text/css" href="resources/css/student.css"/>
<script type="text/javascript" src="resources/js/WebCalendar.js"></script>
<title>学生查询页面</title>
</head>
<body>
<%
         DesData des = new DesData();
         int stuId = Integer.parseInt(des.decrypt(ParamUtil.getString(request,"stuId","4d3d3f222d4c6e08")));
         String time1 = DateTime.SimpleDate();
         int cy = ParamStuyearControl.getCurrentStuyearId();
	  	 if(ParamStuyearControl.getStuyearIdByTime(DateTime.SimpleDate())!=0){
	  	        time1 = ParamUtil.getString(request,"time1",ParamStuyearControl.getStuyear(ParamStuyearControl.getStuyearIdByTime(DateTime.SimpleDate())).getStartTime());//默认为本学期开学时间
	  	     }
  	     String time2 = ParamUtil.getString(request,"time2",DateTime.SimpleDate());
  	     int courseClassId = ParamUtil.getInt(request,"courseClassId",0);
         if(stuId>0){
        	 Student s = StudentControl.getStudent(stuId);
         %>
          <%
        	      List<CourseClass> ccs = CourseClassControl.getAllCourseClassIdByClassIdAndStuyear(Integer.parseInt(s.getClassId()),ParamStuyearControl.getCurrentStuyearId());
        	      if(ccs.size()>0){%>
			        	 <form action="studentResult.jsp" method="post">
			        	 <table class="table">
			        	 <tr class="odd">
			        	 <td>选择课程&nbsp;&nbsp;&nbsp;&nbsp;<select name="courseClassId">
			        	<%
					        	      for(CourseClass cc:ccs){
					        	 %>
					        	 <option value="<%=cc.getId() %>"><%=ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName() %></option>
					        	 <%} %>
					        	 </select>
					        	 </td>
			        	 <td>开始时间&nbsp;&nbsp;&nbsp;&nbsp;<input id="time1" type='text'  name="time1" onclick="SelectDate(this,'','','yyyy-MM-dd')"  readonly style="cursor:pointer"  value="<%=time1 %>"/></td>
			             <td>结束时间&nbsp;&nbsp;&nbsp;&nbsp;<input id="time2" type='text'  name="time2" onclick="SelectDate(this,'','','yyyy-MM-dd')"  readonly style="cursor:pointer"  value="<%=time2 %>"/></td>
			        	<td><input type="hidden" name="stuId" value="<%=des.encrypt(String.valueOf(stuId)) %>"><input type="submit" value="确认" /></td>
			        	</tr>
			        	</table>
			        	</form>
			        	 <%
						            if(courseClassId>0){
								        	 
							        	CourseClass nowcc  = CourseClassControl.getCourseClassById(courseClassId); 
						            	 int CQ_CD=AttendanceDetailControl.getCount(2,s.getId(),courseClassId+"",cy,time1,time2);
							        	 int CQ_QQ = AttendanceDetailControl.getCount(3,s.getId(),courseClassId+"",cy,time1,time2);
							        	 int CQ_BJ = AttendanceDetailControl.getCount(4,s.getId(),courseClassId+"",cy,time1,time2);
							        	 int CQ_SJ = AttendanceDetailControl.getCount(5,s.getId(),courseClassId+"",cy,time1,time2);
							        	 float totalQQ= (float)CQ_CD/3+(float)CQ_BJ/2+CQ_SJ+CQ_QQ; 
							        	 
							        	 int TX_A = DictationControl.getCount(s.getId(),"A",courseClassId,cy,time1,time2);
							        	 int TX_B = DictationControl.getCount(s.getId(),"B",courseClassId,cy,time1,time2);
							        	 int TX_C = DictationControl.getCount(s.getId(),"C",courseClassId,cy,time1,time2);
							        	 int TX_D = DictationControl.getCount(s.getId(),"D",courseClassId,cy,time1,time2);
							        	 
							        	 int ZY_A = HomeworkControl.getCount(s.getId(),"A",courseClassId,cy,time1,time2);
							        	 int ZY_B = HomeworkControl.getCount(s.getId(),"B",courseClassId,cy,time1,time2);
							        	 int ZY_C = HomeworkControl.getCount(s.getId(),"C",courseClassId,cy,time1,time2);
							        	 int ZY_D = HomeworkControl.getCount(s.getId(),"D",courseClassId,cy,time1,time2);
							        	 %>
							        	 <form>
							        	 <fieldset>
							        	 
							        	 <p class="name"><%=s.getChineseName() %>在<%=ParamCourseControl.getCourseById(nowcc.getCourseId()).getCourseName() %>上的相关表现</p>
							        	 <table class="table">
							        	  <caption>出勤情况(/次)</caption>
							        	 <tr>
							        	 <th width="20%">迟到</th>
							        	 <th width="20%">缺勤</th>
							        	 <th width="20%">病假</th>
							        	 <th width="20%">事假</th>
							        	 <th>折合为缺勤次数</th>
							        	 </tr>
							        	 <tr>
							        	 <td><img src="resources/icons/a.png"/> x <%=CQ_CD %></td>
							        	 <td><img src="resources/icons/b.png"/> x <%=CQ_QQ %></td>
							        	 <td><img src="resources/icons/c.png"/> x <%=CQ_BJ %></td>
							        	 <td><img src="resources/icons/d.png"/> x <%=CQ_SJ %></td>
							        	 <td><img src="resources/icons/e.png"/> x <%=totalQQ %></td>
							        	 </tr>
							        	 </table>
							        	 
							        	  <table class="table">
							        	 <caption>听写情况</caption>
							        	 <tr>
							        	 <th>A</th>
							        	 <th>B</th>
							        	 <th>C</th>
							        	 <th>D</th>
							        	 </tr>
							        	 <tr>
							        	 <td><img src="resources/icons/1.png"/> x <%=TX_A %></td>
							        	 <td><img src="resources/icons/2.png"/> x <%=TX_B %></td>
							        	 <td><img src="resources/icons/3.png"/> x <%=TX_C %></td>
							        	 <td><img src="resources/icons/4.png"/> x <%=TX_D %></td>
							        	 </tr>
							        	 </table>
							        	  <table class="table">
							        	  <caption>作业</caption>
							        	 <tr>
							        	 <th>A</th>
							        	 <th>B</th>
							        	 <th>C</th>
							        	 <th>D</th>
							        	 </tr>
							        	 <tr>
							        	 <td><img src="resources/icons/1.png"/> x <%=ZY_A %></td>
							        	 <td><img src="resources/icons/2.png"/> x <%=ZY_B %></td>
							        	 <td><img src="resources/icons/3.png"/> x <%=ZY_C %></td>
							        	 <td><img src="resources/icons/4.png"/> x <%=ZY_D %></td>
							        	 </tr>
							        	 </table>
							        	 </fieldset>
							        	 </form>
		        	 <%
						         }else{
						        	 out.print("<table class='table'><tr><td>请选择一门课程以查看详细情况</td></tr></table>");
						         }
        	     }else{
                	 out.print("<table class='table'><tr><td>抱歉，我们尚未找到该学生的相关课程信息</td></tr></table>");
                 }
         }else{
        	 out.print("<table class='table'><tr><td>抱歉，没有找到该学生的相关信息,请确认操作是否有误</td></tr></table>");
         }           
        	   
%>
<br/><br/><br/><br/><br/>
</body>
</html>